<?php

/*************************************************/
/*     __            __    ____                  */
/*    / / ___  ____ / /_  / __/__  ____ __ ___   */
/*   / /_/ -_|/ __//  _/ _\ \/ ° // __// // _ \  */
/*  /___/\__//_/  /_/   /___/\__//_/  /_//_//_/  */
/*                                               */
/*************************************************/

/**
 * Classe représentant l'objet Menu
 * @author Molinier Danik
 * @package modele
 */
class Menu{

	/**
	 * tableau contenant les menu
	 * @var Array
	 */
	protected $menuTab;

	/**
	 * tableau contenant les url
	 * @var Array
	 */
	protected $menUrl;

	/**
	 * Constructeur
	 */
	public function Menu(){
		$this->menuTab = array();
		$this->menUrl  = array();
		$this->menuAdmin();
		$this->ajoutMenu("Actualite", "index.php");
		$this->ajoutMenu("Effectif", "index.php?module=Utilisateur&action=list");
	}

	public function ajoutMenu($nom, $url){
		$this->menuTab[$nom] = false;
		$this->menUrl[$nom]=$url;
	}

	public function select($nom){
		$this->menuTab[$nom] = true;
	}

	public function supprMenu($nom){
		Utile::supCaseTab($this->menuTab, $nom);
		Utile::supCaseTab($this->menUrl, $nom);
	}

	public function unSelect($nom){
		$this->menuTab[$nom] = false;
	}

	public function __toString(){
		$retHtml = "
		<span >";
		foreach($this->menuTab as $key=>$value){
			if($value){$cls="menusel";}else{$cls="menu";}
			$retHtml .= "
			<span class=\"".$cls."\"><a href=\"".$this->menUrl[$key]."\">".$key."</a></span>";
		}
		$retHtml .="
		</span>";

		return $retHtml;
	}

	public function menuAdmin(){
		if(isset($_SESSION['utilisateur'])){
			if($_SESSION['utilisateur']){
				$utilisateur = $_SESSION['utilisateur'];

				if($utilisateur->getAttr('droit') == 0){
					$this->ajoutMenu('Administration', "index.php?module=Utilisateur&action=admin");
				}
			}
		}
	}

	
}
?>